#include<iostream>
using namespace std;
char s[85][85];
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n;
		memset(s, ' ', sizeof(s));
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (i == j || i + j == n + 1) {
					s[i][j] = 'X';
				}
			}
		}
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (j > n / 2) {
					if (s[i][j] == 'X') {
						cout << "X";
						break;
					}
				}
				cout << s[i][j];
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}